Skip to content

Conversation

@dkjung
Copy link
Collaborator

@dkjung dkjung commented Nov 18, 2025

This PR adds CUDA context management files (cuda_context.h and cuda_context.cpp) that provide similar functionality to the existing OpenCL context. The changes include:

  • Implementation of CudaContext class inheriting from Context and Singleton
  • CUDA kernel management and execution interfaces
  • Build system updates to support CUDA with enable-cuda option
  • Conditional linking of CUDA runtime library for both Windows and Linux
  • Addition of enable-cuda option in meson_options.txt
  • Implementation of RMSNorm CUDA kernel and build configuration

Signed-off-by: Daekyoung Jung [email protected]

Adds CUDA context management files (cuda_context.h
and cuda_context.cpp) that provide similar
functionality to the existing OpenCL context.

The changes include:

- CudaContext class inheriting from Context and Singleton
- CUDA kernel management and execution interfaces
- Build system updates to support CUDA with enable-cuda option
- Conditional linking of CUDA runtime library for both Windows and Linux
- Addition of enable-cuda option in meson_options.txt

Signed-off-by: Daekyoung Jung <[email protected]>
@jijoongmoon
Copy link
Collaborator

Could you check the CI and then We will review once all the ci pass.

@EunjuYang
Copy link
Contributor

I think the commit body of bc7cec0 is missing. Please add some messages to the body instead of putting all messages in the title.

@djeong20
Copy link
Contributor

Please check the comments in #3562

foreach kernel : cuda_sources
obj_name = kernel.replace('.cu', '.o')
obj = custom_target(obj_name,
command: [nvcc, '-c', '-Xcompiler', '/MD', '@INPUT@', '-o', '@OUTPUT@'],
Copy link
Member

@myungjoo myungjoo Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/MD is for MSVC++. This expression should check if it's for Windows/MSVCC++.
For linux, add appropriate compiler option (-fPIC ? )

#endif

#ifdef ENABLE_CUDA
auto &cuda_context = nntrainer::CudaContext::Global();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to add #include "cuda_context.h".

namespace nntrainer {
std::mutex cuda_factory_mutex;

void CudaContext::initialize() noexcept {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to let the caller of initialize() unaware of the init error?

This commit adds CUDA context management files (cuda_context.h and cuda_context.cpp)
that provide similar functionality to the existing OpenCL context.

The changes include:

- Implementation of CudaContext class inheriting from Context and Singleton
- CUDA kernel management and execution interface
- Build system updates to support CUDA with enable-cuda meson_options
- Conditional linking of CUDA runtime library for both Windows and Linux
- Addition of enable-cuda option in meson_options.txt
- Implementation of RMSNorm CUDA kernel and build configuration

Signed-off-by: Daekyoung Jung <[email protected]>
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants